#include "command.h"

int _history(char *argv[])
{
	/* check the number of cmd-line parameters is correct */
	int argc = 0;
	for (char **ptr = argv; *ptr != NULL; ptr++)
		argc++;

	if (argc != 1) {
		fprintf(stderr, "Usage: histroy\n");
		return -1;
	}

	char line[CMD_LINE_BUFSIZE];

	FILE *file = fopen(CMD_HST_FILE, "r");
	if (!file) {
		fprintf(stderr, "histroy error: fopen\n");
		return -1;
	}

	while (fgets(line, sizeof(line), file) != NULL) {
		printf("%s", line);
		fflush(stdout);
	}

	fclose(file);

	return 0;
}
